package cn.mayaslight.wechat.api;

import cn.mayaslight.common.annotation.HttpWithParam;
import cn.mayaslight.common.param.IParamIn;
import cn.mayaslight.common.springbean.APICaller;
import cn.mayaslight.wechat.api.bean.SnsToken;
import cn.mayaslight.wechat.api.bean.User;
import cn.mayaslight.wechat.api.params.WithTokenParam;

public class SnsAPI extends BaseAPI {

	public static SnsToken oauth2AccessToken(final String appid, final String secret, final String code) {
		return APICaller.call(new IParamIn() {
			
			@HttpWithParam("appid")
			private String _appid = appid;
			
			@HttpWithParam("secret")
			private String _secret = secret;
			
			@HttpWithParam("code")
			private String _code = code;
			
			@HttpWithParam("grant_type")
			private String grantType = "authorization_code";
			
			public String getApiKey() {
				// TODO Auto-generated method stub
				return null;
			}
		}, SnsToken.class);
	}

	public static SnsToken oauth2RefreshToken(final String appid, final String refreshToken) {
		return APICaller.call(new IParamIn() {
			
			@HttpWithParam("appid")
			private String _appid = appid;
			
			@HttpWithParam("refresh_token")
			private String _refreshToken = refreshToken;
			
			@HttpWithParam("grant_type")
			private String grantType = "refresh_token";
			
			public String getApiKey() {
				// TODO Auto-generated method stub
				return null;
			}
		}, SnsToken.class);
	}

	public static User userinfo(final String openid, final String lang) {
		return APICaller.call(new WithTokenParam() {
			
			@HttpWithParam("openid")
			private String _openid = openid;
			
			@HttpWithParam("lang")
			private String _lang = lang;
			
			public String getApiKey() {
				// TODO Auto-generated method stub
				return null;
			}
		}, User.class);
	}

}
